<?php

namespace api\web\controller;

use api\web\model\NewsModel;
use cmf\controller\RestBaseController;
use think\facade\Db;

class NewsController extends RestBaseController
{
    public function index()
    {
        $list = Db::name('news')
            ->select();
        $this->success('院部新闻',$list);
    }

    public function content()
    {
        $id = input('id/d');
        if(empty($id))
        {
            $this->error('id不能为空');
        }
        $res = NewsModel::find($id);
        $res['content'] = cmf_replace_content_file_url(htmlspecialchars_decode($res['content']));
        $this->success('查看文章详情',$res);
    }
}